﻿<TreeView x:Class="CodeSHARPer.View.FolderBrowseTreeView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:models="clr-namespace:CodeSHARPer.Model"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" >

    <TreeView.ItemContainerStyle>
        <Style TargetType="{x:Type TreeViewItem}">
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="FontWeight" Value="Bold" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </TreeView.ItemContainerStyle>
    <TreeView.Resources>
        <HierarchicalDataTemplate DataType="{x:Type models:FolderRoot}"
                                          ItemsSource="{Binding Children}">
            <StackPanel Orientation="Horizontal"
                                VerticalAlignment="Stretch"
                                Margin="0,5,0,5">
                <Image Source="{Binding Path=Image, Mode=OneTime}" Stretch="Fill" />
                <TextBlock Text="{Binding Name}" Margin="5,0" />
            </StackPanel>
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate DataType="{x:Type models:FolderItem}"
                                  ItemsSource="{Binding Children}">
            <StackPanel Orientation="Horizontal"
                                VerticalAlignment="Stretch"
                                Margin="0,2,0,2">
                <Image Source="{Binding Path=Image, Mode=OneTime}" Stretch="Fill" />
                <TextBlock Text="{Binding Name}" Margin="5,0">
                    <TextBlock.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="Open container folder" Command="{Binding OpenContainerFolderCommand}"/>
                        </ContextMenu>
                    </TextBlock.ContextMenu>
                </TextBlock>
            </StackPanel>
        </HierarchicalDataTemplate>
    </TreeView.Resources>
</TreeView>
